// eslint-disable-next-line @typescript-eslint/no-var-requires
const FileManagerPlugin = require("filemanager-webpack-plugin");

const commonCss = ["//at.alicdn.com/t/font_2187813_hbbrz4uns4.css"];
const cdn = {
  css: [...commonCss]
};
module.exports = {
  publicPath: process.env.NODE_ENV === "production" ? "/web/" : "/",
  css: {
    loaderOptions: {
      sass: {
        // 引入全局变量样式,@使我们设置的别名,执行src目录
        prependData: `
          @import "@/styles/vars.scss";
        `
      }
    }
  },
  chainWebpack: config => {
    // config.resolve.modules
    //   .add(path.resolve(__dirname, 'src'))
    config.plugin("html").tap(args => {
      args[0].cdn = cdn;
      return args;
    });
    return config;
  },
  configureWebpack: {
    plugins: [
      new FileManagerPlugin({
        events: {
          onEnd: {
            copy: [
              { source: "./dist/index.html", destination: "./dist/404.html" }
            ]
          }
        }
      })
    ]
  }
};
